package model

import (
	"github.com/google/uuid"
	"gorm.io/gorm"
)

type Department struct {
	DepartmentId   string `json:"department_id" gorm:"primaryKey;type:varchar(36);column:department_id;"`
	DepartmentName string `json:"department_name" gorm:"type:varchar(255);column:department_name;uniqueIndex;not null;"`
	DepartmentCode string `json:"department_code" gorm:"type:varchar(255);column:department_code;"`
	DepartmentDesc string `json:"department_desc" gorm:"type:text;column:department_desc;"`
}

func (Department) TableName() string {
	return "department"
}

func (u *Department) BeforeCreate(tx *gorm.DB) (err error) {
	u.DepartmentId = uuid.NewString()
	return
}
